﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MediaRecommender.Controller;
using MediaRecommender.Model;  

namespace MediaRecommender
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void LoginButton_Click(object sender, ImageClickEventArgs e)
        {
            /*
            List<User> users = new List<User>();
            DbGateWay.Instance.Retrieve<User>(out users, (x => true));
            foreach (User u in users)
                PasswordLabel.Text = u.Name;
             * */

            var LoginControl = new LoginController();
            if (LoginControl.Login(LoginTextbox.Text, PasswordTextbox.Text))
            {
                Session.Add("Password", PasswordTextbox.Text);
                Session.Add("Username", LoginTextbox.Text);
                Response.Redirect("MediaSelect.aspx");
            }
            else LoginCheckLabel.Text = "Username or password is invalid";
        }

        protected void SignUpButton_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("CreateUser.aspx");
        }
    }
}